import pandas as pd
import os
import pandas as pd

EXCLUDE_FILES = ['通行设施.csv', '室内设施.csv', '地名地址信息.csv', '事件活动.csv']


def get_all_csv(source_path, dest_path):
    res = []
    for fileName in os.listdir(source_path):
        source_file_path = source_path+os.sep+fileName
        if fileName.endswith(".csv") and fileName not in EXCLUDE_FILES:
            res.append(
                (source_file_path, dest_path+os.sep +
                 os.path.splitext(os.path.split(
                     source_file_path)[-1])[0]+".xlsx"
                 )
            )
        elif os.path.isdir(source_file_path):
            res.extend(get_all_csv(source_path+os.sep +
                       fileName, dest_path+os.sep+fileName))
    return res


files = get_all_csv("csv", "csv_type")
for source, dest in files:
    df = pd.read_csv(source, usecols=[
        'LON', 'LAT', 'TYPECODE', 'BASETYPE', 'SUBTYPE', 'CATEGORY'])
    df = df[df.str.contains('|')]